<?php
/**
 * 兼容第三方插件补丁文件
 * @appapi 兼容重整
 */
defined('BY_JYA') or exit('error');
define('IN_WQZ',true);
if($_RQ['m']){
	$_SESSION['m']=$_RQ['m'];
}
if($_SESSION['this']=='manage'){
	$w='Web';
	define('IN_SYS',true);
	define('IN_MANAGE', 1);
}else{
	$w='Mobile';
	define('IN_MOBILE',true);
}
if(!$_SESSION['m']){
	exit('error module');
}
require ROOT_D.'/api/open_jyapi/function.php';
require ROOT_D.'/api/open_jyapi/to_wqz.php';
require ROOT_D.'/api/open_jyapi/account.php';
require ROOT_D.'/api/open_jyapi/tpl'.$w.'.php';

$_AR['access_json']=$_AR['siteurl'];
$pid=pdo_getcolumn('core_plugins',array('name'=>$_SESSION['m']),'id');
if($_SESSION['this']=='manage' && !$_SESSION['isfounder'] && !strexists($_SESSION['user']['plugin_actions'],';'.$pid.';')){
	exit('error module action');
}
$do=trim($_RQ['do']);

if($do=='setting'){
	$obj = WeUtility::createModule($_SESSION['m']);
	$settings=$obj->getSettings();
	$obj->settingsDisplay($settings);
}elseif($do=='rule'){
	require 'reply.php';
}elseif($do=='payresult'){
	if(!$_SESSION['payresult']){
		exit('访问错误，没有支付结果！');
	}
	$params=array(
		'fee'=>$_SESSION['payresult']['fee'],
		'result'=>$_SESSION['payresult']['status']==1?'success':'failed',
		'type'=>$_SESSION['payresult']['pay_type'],
		'tid'=>$_SESSION['payresult']['id'],
		'title'=>$_SESSION['payresult']['title'],
		'from'=>'return'
	);
	unset($_SESSION['payresult']);
	$site = WeUtility::createModuleSite($_SESSION['m']);
	$method = 'payResult';
	$site->$method($params);
}else{
	$site = WeUtility::createModuleSite($_SESSION['m']);
	$method = 'do'.$w.ucfirst($do);
	$res=$site->$method();
	echo $res;
}
exit;
